<template>
  <div class="my-comment" ref="fullHomePage">
    <nav-top title="我的评论" :goback="true"></nav-top>
    <div class="top">
      <img :src="userImg" />
      <p class="username">{{ username }}</p>
      <p class="count">{{ '已贡献评论' + count + '条' }}</p>
    </div>
    <div>
      <div class="comment" v-for="(item, index) in comments" :key="index">
        <div class="hospital">
          <img :src="item.hospitalImg" />
          <p>{{ item.hospital }}</p>
        </div>
        <img class="product-img" :src="item.productImg" />
        <div class="comment-info">
          <p class="product-name">{{ item.product }}</p>
          <p class="comment-time">{{ item.createTime }}</p>
          <p class="comment-contact">{{ item.contact }}</p>
        </div>
        <div class="action">
          <a @click="delComment(index)">
            <img src="/static/icon/comments-del.png" />
            <p>删除</p>
          </a>
        </div>
      </div>
    </div>
    <van-popup v-model="delShow">
      <div class="del-popup">
        <p>确定删除这条评论吗？</p>
        <button @click="delShow=false">取消</button>
        <button @click="delSubmit">确定</button>
      </div>
    </van-popup>
  </div>
</template>

<script>
import NavTop from "@/components/nav/navBar";

export default {
  components: {
    NavTop
  },
  name: "MyComment",
  data() {
    return {
      delShow: false,
      delIndex: -1,
      username: "用户名称",
      userImg: "/static/icon/self/default-avatar.png",
      count: 1,
      comments: [
        {
          hospital: "医院医111",
          hospitalImg: "/static/icon/self/default-avatar.png",
          product: "产品产品产1111",
          productImg: "/static/icon/self/default-avatar.png",
          createTime: "2019.08.01",
          contact: "评论评论评1111"
        },
        {
          hospital:
            "医院医院医院医院医院医院医院医院医院医院医院医院院医院医院医院医院医院医院医院",
          hospitalImg: "/static/icon/self/default-avatar.png",
          product: "产品产品产品产品产品产品产品产品产品产品产品产品产品",
          productImg: "/static/icon/self/default-avatar.png",
          createTime: "2019.08.01",
          contact:
            "评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论，评论评论评论评论评论"
        },
        {
          hospital: "医院医",
          hospitalImg: "/static/icon/self/default-avatar.png",
          product: "产品产品产",
          productImg: "/static/icon/self/default-avatar.png",
          createTime: "2019.08.01",
          contact: "评论评论评"
        }
      ],
      clientHeight: ""
    };
  },
  mounted() {
    this.clientHeight = `${document.documentElement.clientHeight}`;
    window.onresize = function temp() {
      this.clientHeight = `${document.documentElement.clientHeight}`;
    };
  },
  watch: {
    clientHeight: function() {
      this.changeFixed(this.clientHeight);
    }
  },
  methods: {
    changeFixed(clientHeight) {
      this.$refs.fullHomePage.style.height = clientHeight + "px";
    },
    delComment(index) {
      this.delShow = true;
      this.delIndex = index;
    },
    delSubmit() {
      console.log(this.comments[this.delIndex].product);
      this.comments.splice(this.delIndex, 1);
      this.delShow = false;
    }
  }
};
</script>

 <style lang="scss" scoped>
.my-comment {
  background: #f5f5f7;
  margin-top: 42px;
  p {
    margin: 0;
    line-height: 1em;
  }
  .top {
    position: relative;
    background-image: url("/static/icon/background-img/comment-top-background.png");
    width: 320px;
    height: 132px;
    background-size: 100% 100%;
    text-align: center;
    img {
      width: 50px;
      height: 50px;
      margin: 14px auto 12px auto;
      border-radius: 50%;
    }
    p {
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(251, 251, 251, 1);
    }
    .count {
      margin-top: 14px;
      font-size: 11px;
    }
  }
  .comment {
    background-color: #ffffff;
    border-bottom: 6px solid #f5f5f7;
    .hospital {
      font-size: 0;
      height: 36px;
      border-bottom: 1px solid #f5f5f7;
      clear: both;
      img {
        width: 22px;
        height: 22px;
        margin: 8px 7px 6px 11px;
        float: left;
        border-radius: 50%;
      }
      p {
        width: 260px;
        padding-top: 13px;
        font-size: 11px;
        height: 11px;
        line-height: 12px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(59, 59, 59, 1);
      }
    }
    .product-img {
      width: 33px;
      height: 33px;
      border-radius: 50%;
      margin: 8px 11px 0 15px;
      float: left;
    }
    .comment-info {
      float: left;
      width: 261px;
      position: relative;
      border-bottom: 1px solid #f5f5f7;
      .product-name {
        padding-top: 19px;
        margin-bottom: 12px;
        width: 160px;
        font-size: 11px;
        height: 11px;
        line-height: 12px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(59, 59, 59, 1);
      }
      .comment-time {
        font-size: 9px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(102, 102, 102, 1);
        position: absolute;
        right: 18px;
        top: 20px;
      }
      .comment-contact {
        font-size: 11px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(59, 59, 59, 1);
        line-height: 16px;
        padding-bottom: 8px;
        width: 244px;
      }
    }
    .hospital p,
    .product-name {
      display: -webkit-box;
      /*! autoprefixer: off */
      -webkit-box-orient: vertical;
      /*! autoprefixer: on */
      -webkit-line-clamp: 1;
      overflow: hidden;
    }
    .action {
      clear: both;
      width: 320px;
      height: 31px;
      position: relative;
      img {
        width: 17px;
        height: 17px;
        position: absolute;
        top: 6px;
        right: 43px;
      }
      p {
        font-size: 11px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: rgba(102, 102, 102, 1);
        position: absolute;
        top: 9px;
        right: 19px;
        width: 23px;
      }
    }
  }
  .del-popup {
    width: 248px;
    height: 94px;
    text-align: center;
    p {
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(59, 59, 59, 1);
      padding: 22px 0;
      border-bottom: 1px solid #f5f5f7;
    }
    button {
      width: 120px;
      height: 36px;
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: rgba(59, 59, 59, 1);
      background-color: #ffffff;
      border: none;
      padding: 0;
      margin: 0;
      &:last-child{
color:rgba(6,164,79,1);
      border-left: 1px solid #f5f5f7;
      }
    }
  }
}
</style>
